package data_structure

type Pennant struct {
	Val   int32      // 图节点编号
	Left  *Pennant // 左节点
	Right *Pennant // 右节点
}

func NewPennant(v int32) *Pennant {
	return &Pennant{
		Val: v,
	}
}

// 结合操作
func (p *Pennant) Union(another *Pennant) *Pennant {
	left := p.Left
	another.Right = left
	p.Left = another
	return p
}

// 分离操作
func (p *Pennant) Split() *Pennant {
	another := p.Left
	right := another.Right
	another.Right = nil
	p.Left = right
	return another
}
